import SwiftUI

// conforms to the View protocol
// describes the view’s content and layout.
struct ContentView: View {
    @State private var selection: Tab = .featured
    
    enum Tab {
        case featured
        case list
    }
    
    // You can combine and embed multiple views in **stacks**, which group views together horizontally, vertically, or back-to-front.
    var body: some View {
        TabView(selection: $selection) {
            CategoryHome()
                .tabItem {
                    Label("Featured", systemImage: "star")
                }
                // The tag(_:) modifier on each of the views matches one of the possible values that the selection property can take 
                // so the TabView can coordinate which view to display when the user makes a selection in the user interface
                .tag(Tab.featured)

            LandmarkList()
                .tabItem {
                    Label("List", systemImage: "list.bullet")
                }
                .tag(Tab.list)
        }
    }
}

#Preview {
    ContentView()
        // A preview fails if any subview requires a model object in the environment, but the view you are previewing doesn’t have the environment(_:) modifier.
        .environment(ModelData())
}
